<template>
  <div class="popWin" :style="{ zIndex: zIndex }" v-if="show">
    <div class="popWinBg"></div>
    <div class="popWinMain" ref="popWinMain" :style="{height:this.height}">
      <bg></bg>
      <div class="popWinMainInner" v-if="showInner">
        <div class="tables">
          <div class="slot" style="height: 98%">
            <p class="titleName" style="font-size:20px;font-weight:bold;margin-top: 0">{{ title }}</p>
            <el-table :data="tableDataList" height="100%" style="width: 100%" stripe @row-click="handleRowClick" :row-style="{fontSize:'14px',fontWeight:'bold'}" :header-row-style="{fontSize:'14px',fontWeight:'bold'}">
              <el-table-column :label="title.includes('报价')?'报价负责人':title.includes('回款')?'回款认领人':'销售负责人'" prop="name" align="center"></el-table-column>
              <el-table-column :label="title.includes('客户')?'客户数量':title.includes('商机')?'商机数量':title.includes('合同')?'合同金额汇总':title.includes('投标')?'投标数量':title.includes('回款')?'回款金额汇总':title.includes('报价')?'报价金额汇总':'新增数量'" prop="num" align="center">
                <template slot-scope="scope">
                  <span class="bs" style="font-size:14px !important;font-weight:bold">{{ scope.row.num.toLocaleString() }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button type="text" @click="handleDetail(scope.row)" style="font-size:12px !important;font-weight:bold">查看明细</el-button>
                </template>
              </el-table-column>
            </el-table>
            <table class="horizontal-table">
              <tr>
                <th class="tb50">新增合计</th>
                <td class="tb50">{{ (tableDataList.reduce((pre, cur) => pre + cur.num, 0)).toLocaleString() }}</td>
              </tr>
            </table>
          </div>
        </div>
        <div class="footerLine"></div>
        <div class="footerBut">
          <!--<div class="footerButItem" @click="getHide"><span>取消</span></div>-->
          <div class="footerButItem" @click="getConfirm"><span>关闭</span></div>
        </div>
      </div>
    </div>
    <pop ref="pop"></pop>
  </div>
</template>

<script>
import gsap from 'gsap'
import bg from './bg/index.vue'
import util from '@/utils/util.js'
import pop from './pop1'

export default {
  data() {
    return {
      show: false,
      showInner: false,
      obj: {},
      tableData: {},
      title: '',
      tableDataList: [],
      amountAll: 0
    }
  },
  components: {bg,pop},
  mounted() {
    if (this.appendToBody) {
      const bodyElement = document.querySelector('body')
      bodyElement.appendChild(this.$el)
    }
  },
  props: {
    width: {
      type: String,
      default() {
        return '85%'
      }
    },
    height: {
      type: String,
      default() {
        return '659px'
      }
    },
    // 弹窗层级,默认最大值
    zIndex: {
      type: Number,
      default: 147
    },
    // 是否将组件插入到body中 默认true
    appendToBody: {
      type: Boolean,
      default: true
    },
  },
  methods: {
    handleDetail(v){
      console.log(v)
      this.$refs.pop.getShow(v,this.title)
    },
    handleRowClick(row, column, event) {
      this.obj = row
    },
    //使用节流
    getShow: util.throttle(function (v) {
      console.log(v)
      this.show = true
      this.tableDataList = v.arr
      this.title = v.seriesName
      this.amountAll = 10000
      /*this.tableDataList = v.data
      this.title = v.province
      v.data.forEach(item=>{
        this.amountAll += item.contractAmount
      })*/
      this.$nextTick(() => {
        gsap.to(this.$refs.popWinMain, {
          duration: 0.5,
          width: '1200px',
          onComplete: () => {
            this.showInner = true
          }
        })
      })
    }, 500),
    getConfirm() {
      this.getHide()
    },
    getHide() {
      this.showInner = false
      this.title = ''
      this.tableDataList = []
      this.amountAll = 0
      this.$nextTick(() => {
        gsap.to(this.$refs.popWinMain, {
          duration: 0.5,
          width: '0%',
          onComplete: () => {
            this.show = false
          }
        })
      })
      this.tableData = {}
    }
  }
}
</script>

<style lang="scss" scoped>
.popWinBg {
  position: fixed;
  z-index: 8;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: initial;
}

.popWin {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  position: fixed;
  z-index: 10;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  pointer-events: none;

}

.popWinMain {
  pointer-events: initial;
  position: relative;
  overflow: hidden;
  width: 0;
  max-width: 1642px;
  height: 85%;
  max-height: 1004px;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  //background: url("./bg/assets/bg.png") no-repeat;
  //background-size: 100% 100%;
  .popClose {
    position: absolute;
    right: 10px;
    top: 10px;
    background: url("./assets/icon_close.png") no-repeat;
    width: 16px;
    height: 16px;
    background-size: 100% 100%;
    cursor: pointer;
    z-index: 1;
    //transform: rotateX(180deg);
  }

  .popWinMainInner {
    margin-top: 40px;
    position: relative;
    width: calc(100% - 30px);
    height: calc(100% - 40px);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap;
    flex-direction: column;
    align-content: flex-start;

    .tables {
      //background:#fff;
      height: 100%;
      width: 100%;
      overflow-y: auto;

      .slot {
        position: relative;
        width: 100%;
        //height: calc(100% - 170px);
        margin-top: 0;
        overflow: auto;
        padding: 0 20px;
        box-sizing: border-box;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex-wrap: nowrap;
        flex-direction: column;
        align-content: flex-start;

        .titleName {
          margin: 24px auto 10px auto;
          color: #fff;
          font-size: 20px;
        }

        /* 表格基本样式 */
        .horizontal-table {
          width: 100%; /* 表格宽度 */
          border-collapse: collapse; /* 合并边框 */
          margin: 0; /* 外边距 */
        }

        /* 表头样式 */
        .horizontal-table th {
          background-color: #053275; /* 背景色 */
          padding: 10px; /* 内边距 */
          text-align: center; /* 文本对齐 */
          border: 1px solid rgba(163, 186, 239, 0.2); /* 边框 */
          color: #eeaf0a;
          font-weight: 600;
        }

        /* 单元格样式 */
        .horizontal-table td {
          padding: 10px; /* 内边距 */
          background: #093b7d;
          text-align: left; /* 文本对齐 */
          border: 1px solid rgba(163, 186, 239, 0.2); /* 边框 */
          color: #a3baef;
        }

        .noneBorder td, .noneBorder th {
          border: 1px solid rgba(163, 186, 239, 0.2);
        }

        .tb50 {
          width: 50%;
        }

        .tb25 {
          width: 25%;
        }

        .tb12 {
          width: 12.5%;
        }
      }
    }

    // 滚动条宽度
    .tables::-webkit-scrollbar {
      width: 6px;
    }

    // 滚动条轨道
    .tables::-webkit-scrollbar-track {
      background-color: rgba(2, 6, 23, 0.5);
    }

    // 小滑块
    .tables::-webkit-scrollbar-thumb {
      background: #56B5FF;
      border-radius: 3px;
    }
  }
}

.footerLine {
  background: url("./assets/footerLine.png") no-repeat;
  background-size: 100% 100%;
  height: 40px;
  width: 100%;
  position: relative;
  bottom: 0;
  margin-top: -30px;
}

.footerBut {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  width: 100%;
  height: 100px;

  .footerButItem {
    background: url("./assets/butbg.png") no-repeat;
    background-size: 100% 100%;
    width: 130px;
    height: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-left: 45px;
    margin-right: 45px;
    cursor: pointer;

    span {
      font-size: 18px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: #89ADCE;
      letter-spacing: 20px;
      text-indent: 20px;
    }
  }

  .footerButItem:hover {
    background: url("./assets/butbgActive.png") no-repeat;
    background-size: 100% 100%;
    width: 130px;
    height: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-left: 45px;
    margin-right: 45px;
    cursor: pointer;

    span {
      font-size: 18px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: rgba(71, 200, 255, 1);
      letter-spacing: 20px;
      text-indent: 20px;
    }
  }
}
</style>
<style lang="scss">
.popWinMainInner {
  position: relative;
  height: 100%;
  width: 100%;

  .lx {
    width: 68px;
    height: 26px;
    margin: auto;
    background: rgba(#47C8FF, 0.2);
    border-radius: 2px 2px 2px 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    font-size: 14px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    color: #00FFFF;
  }

  .el-table, .el-table__expanded-cell {
    background: none !important;
  }

  .el-table tr {
    background: #053275 !important;
  }

  .el-table td.el-table__cell div {
    color: rgba(184, 204, 255, 1) !important;
  }

  .el-table td.el-table__cell, .el-table th.el-table__cell.is-leaf {
    border: none !important;
  }

  .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
    background: #093b7d;

    .lx {
      width: 68px;
      height: 26px;
      margin: auto;
      background: rgba(255, 184, 1, 0.2);
      border-radius: 2px 2px 2px 2px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      font-size: 14px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: rgba(255, 184, 1, 1);
    }
  }

  .el-table--enable-row-hover .el-table__body tr:hover > td {
    background: #0c4693 !important;
  }

  .el-table th.el-table__cell {
    background: #1455aa !important;
    color: rgba(71, 200, 255, 1);
  }

  .el-table--border::after, .el-table--group::after, .el-table::before {
    background-color: rgba(#EBEEF5, 0);
  }

  .el-table--border th.el-table__cell, .el-table__fixed-right-patch {
    border: none !important;
    border-bottom: 1px solid rgba(163, 186, 239, 0.2) !important;
  }

  .el-table--border, .el-table--group {
    border: none !important;
  }

  .el-table--border th.el-table__cell.gutter:last-of-type {
    border: none !important;
  }

  .bs {
    font-size: 16px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    color: #FFB801;
  }

  //横向
  //横向horizontal
  .is-scrolling-left::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  //滚动条滑块
  .is-scrolling-left::-webkit-scrollbar-thumb {
    //滚动条里面小方块
    background: #56B5FF;
    border-radius: 5px;
  }

  //滚动条轨道
  .is-scrolling-left::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

  //横向滚动右侧
  .is-scrolling-right::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  //滚动条滑块
  .is-scrolling-right::-webkit-scrollbar-thumb {
    //滚动条里面小方块
    background: #56B5FF;
    border-radius: 5px;
  }

  //滚动条轨道
  .is-scrolling-right::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

  //横向滚动中部
  .is-scrolling-middle::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  //滚动条滑块
  .is-scrolling-middle::-webkit-scrollbar-thumb {
    //滚动条里面小方块
    background: #56B5FF;
    border-radius: 5px;
  }

  //滚动条轨道
  .is-scrolling-middle::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

  //纵向滚动条
  .is-scrolling-none::-webkit-scrollbar {
    width: 0px;
    height: 200px;
  }

  //滚动条滑块
  .is-scrolling-none::-webkit-scrollbar-thumb {
    //滚动条里面小方块
    border-radius: 2px;
    box-shadow: inset 0 0 5px #189abc;
    background: #115091;
  }

  //滚动条轨道
  .is-scrolling-none::-webkit-scrollbar-track {
    //滚动条里面轨道
    box-shadow: inset 0 0 5px #1f4962;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0);
  }
}
</style>
